#include <bits/stdc++.h>
using namespace std;
bool isdig(char c){return '0' <=c && c <= '9';} 
const int N = 1e5 + 5;
const int M = 5005;
typedef long long ll; 
ll read(){
    ll x = 0 , f = 1;
    char c = getchar();
    while (!isdig(c)){
        if (c == '-') f = -1;
        c = getchar();
    }
    while (isdig(c)){
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x * f;
}
void write(ll x){
    if (x < 0){
        x = -x;
        putchar('-');
    }
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}
ll a[N],b[N];
int vis[N];
ll remain[N];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out" , "w",stdout);
    ll n = read();
    for (int i = 1 ; i <= n ;i ++) a[i] = read();
    sort(a + 1 , a + n + 1);
    ll m = 0ll;
    for (int i = 1 ; i <= n ; i ++){
        if (!vis[a[i]]) b[++ m] = a[i];
        vis[a[i]] ++;
    }
    ll rest = vis[b[m]];
    remain[m] = vis[b[m]];
    for (int i = m - 1 ; i >= 1 ; i --){
        if (rest >= vis[b[i]]){
            rest -= vis[b[i]];
            remain[i] = 0;
            rest += vis[b[i]];
        }
        else if (rest < vis[b[i]]){
            remain[i] = vis[b[i]] - rest;
            rest = vis[b[i]];
        }
    }
    ll ans = 0 ;
    for (int i = 1 ; i <= m ; i ++) ans += remain[i];
    write(ans);
    return 0;
}